package com.eedi.framework.user.convert;

import com.eedi.framework.common.enums.CommonStatusEnum;
import com.eedi.framework.common.enums.UserTypeEnum;
import com.eedi.framework.user.controller.org.vo.OrgUserAccountImportReq;
import com.eedi.framework.user.controller.org.vo.OrgUserLoginInfoResp;
import com.eedi.framework.user.controller.org.vo.OrgUserProfileEditReq;
import com.eedi.framework.user.controller.org.vo.OrgUserSimpleResp;
import com.eedi.framework.user.controller.org.vo.ext.OrgUserExtReq;
import com.eedi.framework.user.dal.dataobject.OrgUserDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author mumu
 * @date 2024/7/4 16:06
 * @mood happy
 */
@Mapper
public interface OrgUserConvert {

    OrgUserConvert INSTANCE = Mappers.getMapper(OrgUserConvert.class);

    OrgUserLoginInfoResp convert(OrgUserDO orgUserDO);
    List<OrgUserLoginInfoResp> convert(List<OrgUserDO> orgUsers);
    OrgUserDO convert(OrgUserProfileEditReq req);
    OrgUserExtReq convert(OrgUserLoginInfoResp orgUserLoginInfoResp);
    OrgUserDO convert(OrgUserAccountImportReq req);

    default List<OrgUserDO> convertList(List<OrgUserAccountImportReq> listReq){
        if ( listReq == null ) {
            return null;
        }

        List<OrgUserDO> list = new ArrayList<OrgUserDO>( listReq.size() );
        for ( OrgUserAccountImportReq orgUserAccountImportReq : listReq ) {
            OrgUserDO item = convert(orgUserAccountImportReq);
            item.setOrgUserAccountType(UserTypeEnum.MEMBER_OPS);
            item.setOrgUserAccountStatus(CommonStatusEnum.ENABLE);
            list.add(item);
        }
        return list;
    }

    List<OrgUserSimpleResp> convert2SimpleResp(Collection<OrgUserDO> orgUserDO);

}
